<template>
	<view class="waterfall-item-container">
		<view class="waterfall-item" @tap="onTap">
			<image :src="params.image.split(',')[0]" mode="widthFix" @load="emitHeight" @error="emitHeight"
				style="border-top-left-radius:15rpx;border-top-right-radius:15rpx;"></image>
			<view class="content">
				<view
					style="margin-top: 20rpx;font-size: 28rpx;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
					{{params.title}}</view>
				<view class="flex align-center justify-between" style="padding-top:10rpx ;">
					<view class="flex align-center">
						<u-avatar :src="params.userAvatar" size="30"></u-avatar>
						<view style="margin-left: 15rpx;color: rgba(30,30,30,0.3);font-size: 24rpx;">{{params.userNick}}
						</view>
					</view>
					<view class="flex align-center justify-between" style="color: #FF5353;background-color: #fff;width: 114rpx;height: 40rpx;border-radius: 20rpx;padding: 0 10rpx;">
						<image src="../../../../static/find/live.png" style="width:28rpx;height: 28rpx;" mode="">
						</image>
						<text>{{params.clickNum}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "helangWaterfallItem",
		options: {
			virtualHost: true
		},
		props: {
			params: {
				type: Object,
				default () {
					return {}
				}
			},
			tag: {
				type: String | Number,
				default: ''
			},
			index: {
				type: Number,
				default: -1
			}
		},
		data() {
			return {

			};
		},
		methods: {
			// 发出组件高度信息，在此处可以区分正确和错误的加载，给予错误的提示图片
			emitHeight(e) {
				const query = uni.createSelectorQuery().in(this);
				query.select('.waterfall-item-container').boundingClientRect(data => {
					let height = Math.floor(data.height);
					this.$emit("height", height, this.$props.tag);
				}).exec();
			},
			onTap() {
				this.$emit("click", this.$props.index, this.$props.tag);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.waterfall-item {
		// padding: 16rpx;
		background: #F0F3FA;
		border-radius: 15px;
		font-size: 28rpx;
		color: #666;

		image {
			display: block;
			width: 100%;
			// 默认设置一个图片的大约值
			height: 350rpx;
		}

		.content {
			// background: #F0F3FA;
			padding: 10rpx;

			.money {
				color: #fa3534;
				margin-top: 8rpx;
			}

			.label {
				background-color: #fa3534;
				color: #fff;
				font-size: 20rpx;
				padding: 4rpx 16rpx;
				border-radius: 20rpx;
			}

			.shop-name {
				font-size: 20rpx;
				color: #999;
			}
		}
	}
</style>
